﻿using System;
using System.Collections;
using System.Collections.Generic;

namespace Infrastructure.CrossCutting.Configuration
{
    public interface IConfigSection : IDictionary
    {
        /// <summary>
        /// Add section key/value item. 
        /// </summary>
        /// <param name="sectionName">Name of the section.</param>
        /// <param name="key">The key.</param>
        /// <param name="val">The val.</param>
        void AddToSection(string sectionName, string key, Object val);

        /// <summary>
        /// Add to value to the section/key combination. 
        /// </summary>
        /// <param name="sectionName">Name of the section.</param>
        /// <param name="key">The key.</param>
        /// <param name="val">The val.</param>
        /// <param name="overWrite">if set to <c>true</c> [over write].</param>
        void AddToSection(string sectionName, string key, Object val, bool overWrite);

        /// <summary>
        /// Add to value to the section/key combination. 
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="val">The val.</param>
        /// <param name="overWrite">if set to <c>true</c> [over write].</param>
        void AddItem(string key, object val, bool overWrite);

        /// <summary>
        /// Add to value to the section/key combination. 
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="val">The val.</param>
        void AddItem(string key, object val);

        /// <summary>
        /// Determines whether [contains] [the specified section].
        /// </summary>
        /// <param name="section">The section.</param>
        /// <param name="key">The key.</param>
        /// <returns>
        /// 	<c>true</c> if [contains] [the specified section]; otherwise, <c>false</c>.
        /// </returns>
        bool Contains(string section, string key);

        /// <summary>
        /// Gets the specified key.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key">The key.</param>
        /// <returns></returns>
        T Get<T>(string key);

        bool TryGet<T>(string key, out T result);

        /// <summary>
        /// Gets the specified section.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="section">The section.</param>
        /// <param name="key">The key.</param>
        /// <returns></returns>
        T Get<T>(string section, string key);

        bool TryGet<T>(string section, string key, out T result);

        /// <summary>
        /// Gets the specified section.
        /// </summary>
        /// <param name="section">The section.</param>
        /// <param name="key">The key.</param>
        /// <returns></returns>
        Object Get(string section, string key);

        bool TryGet(string key, out object result);

        bool TryGet(string section, string key, out Object result);

        /// <summary>
        /// Get key value if preset, default value otherwise. 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key">The key.</param>
        /// <param name="defaultValue">The default value.</param>
        /// <returns></returns>
        T GetDefault<T>(string key, T defaultValue);

        /// <summary>
        /// Get key value if preset, default value otherwise. 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="section">The section.</param>
        /// <param name="key">The key.</param>
        /// <param name="defaultValue">The default value.</param>
        /// <returns></returns>
        T GetDefault<T>(string section, string key, T defaultValue);

        /// <summary>
        /// Gets the section with the name specified.
        /// </summary>
        /// <param name="sectionName">Name of the section.</param>
        /// <returns></returns>
        IConfigSection GetSection(string sectionName);

        //IConfigSection GetSection(string sectionName, int ndx);

        /// <summary>
        /// Get the section key value using the indexer. 
        /// </summary>
        /// <value></value>
        Object this[string sectionName, string key] { get; set; }

        /// <summary>
        /// Gets or sets the name of this config section.
        /// </summary>
        /// <value>The name.</value>
        string Name { get; set; }

        /// <summary>
        /// Gets the names of the sections.
        /// </summary>
        /// <value>The sections.</value>
        List<string> Sections { get; }
    }

}
